<?php
/**
 * Created by PhpStorm.
 * User: seven
 * Date: 2018/4/5
 * Time: 上午12:00
 */
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);

date_default_timezone_set("Asia/Shanghai");

require __DIR__.'/../Lang3.php';
require __DIR__.'/../PDOManager3.php';
require __DIR__.'/../Resp3.php';

$name = Lang3::getParam('name', '');
$gender = Lang3::getParam('gender', '');
$phone = Lang3::getParam('phone', '');
$birthday = Lang3::getParam('birthday', '');
$id = Lang3::getParam('id', '');

$pdo = PDOManager3::getDB();

if($id != '' && $id > 0){
    PDOManager3::update($pdo, 'vip', [
        'name' => $name,
        'gender' => $gender,
        'phone' => $phone,
        'birthday' => $birthday,
    ], 'id = :id', [
       'id' => $id,
    ]);
    echo Resp3::response_json_ok([
        'id' => $id,
        'name' => $name,
        'gender' => $gender,
        'phone' => $phone,
        'birthday' => $birthday,
    ]);
}else{
    $newId = PDOManager3::insert($pdo, 'vip', [
        'name' => $name,
        'gender' => $gender,
        'phone' => $phone,
        'birthday' => $birthday,
    ]);
    echo Resp3::response_json_ok([
        'id' => $newId,
    ]);
}




// localhost:7888/service/free/lishuai/vp_add.php?name=李二三&gender=女&phone=15011571302&birthday=2014-02-04&id=2
// 114.215.81.196/service/free/lishuai/vp_add.php?name=李二三&gender=女&phone=15011571302&birthday=2014-02-04&id=2


